import * as cc from "cc";
import { GlobalEnum } from "./GlobalEnum";

//玩家数据示例
export default class PlayerDataTemplate {
    private constructor() { }
    public static getData(): any {
        return {
            //第一次登陆时间
            fristLoginTimer: 0,
            //游戏存档数据
            gameData: new PlayerDataType()
        }
    }
}
//玩家数据类型
export class PlayerDataType {
    public curLevel = 1;
    //玩家资源
    public asset = {
        gold: 0,        //金币
        power: 10,      //体力
    };
    //主角皮肤
    public PlayerSkin = {
        cur: 0,         //当前使用的皮肤
        try: -1,        //当前试用的皮肤，-1表示无试用皮肤
        owned: [0],     //已拥有的皮肤
    };
    //当前车辆选择的皮肤
    public useSkin = {
        1: 1,   //类型1
        2: 1,   //类型2
        3: 1,   //类型3
    };
    public carSkin = {
        1: {
            cur: 1,
            try: -1,
            owned: [1],
        },
        2: {
            cur: 1,
            try: -1,
            owned: [1],
        },
        3: {
            cur: 1,
            try: -1,
            owned: [1],
        },
    }
    //商城
    public shopData = {
        //车辆类型
        1: { 1: true }, //摩托
        2: { 1: true }, //越野
        3: { 1: true }, //赛车
    };
    //签到
    public signData = {
        count: -1,
        lastTime: 0,
    };
    //抽奖
    public spinData = {
        count: 0,
        lastTime: 0
    }
}


/**用户信息 */
export class UserInfo {
    public static fristLoginTimer = 0;
    public static needuserinfo = 0;
    protected static _openid = "";
    public static get openid() {
        if (!this._openid) {
            this._openid = cc.sys.localStorage.getItem("openid");
        }
        return this._openid;
    }
    public static set openid(v) {
        this._openid = v;
        cc.sys.localStorage.getItem("openid");
    }

    public static sessid = "aaaa";
    public static userid = "";
}
